package com.bytecodezz.app.toolset.launcher.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.bytecodezz.app.framework.base.adapter.BaseAdapter
import com.bytecodezz.app.framework.base.adapter.BaseViewHolder
import com.bytecodezz.app.toolset.R
import com.bytecodezz.app.toolset.databinding.ItemToolMenuLayoutBinding
import com.bytecodezz.app.toolset.launcher.domain.ToolEntity

/**
 * @author: bytecodezz
 * @version: 1.0
 * @time: 2021/7/8 10:43
 * @package: com.bytecodezz.app.toolset.launcher.adapter
 *
 * @description:
 *
 */
class ToolMenuAdapter : BaseAdapter<ToolEntity>() {
    override fun onCreateHolder(parent: ViewGroup, viewType: Int): BaseViewHolder? {
        return BaseViewHolder(
            ItemToolMenuLayoutBinding.inflate(
                LayoutInflater.from(parent?.context),
                parent,
                false
            )
        )
    }

    override fun convert(
        holder: BaseViewHolder,
        itemData: ToolEntity,
        position: Int,
        payloads: List<ToolEntity>
    ) {
        holder.getViewBinding<ItemToolMenuLayoutBinding>()?.run {
            itemToolIconImv.setImageResource(itemData.iconRes)
            itemToolNameTv.text = itemData.toolName
        }
    }
}